-- status_ratio
-- create by zhuangsl
-- 道具： 概率附加状态

return {
    apply = function(source, target, classId, value)
        -- 概率触发
        local ratio = value.ratio or 0;
        if DungeonM.getRandSeed("status_ratio") % 1000 >= ratio then
            return;
        end

        local condition = table.deepcopy(value);
        condition.ratio = nil;

        -- 必须有状态和回合数
        local status = condition.status;
        assert(status);

        local endRound = condition.end_round;
        assert(endRound);

        if endRound > 0 then
            condition.end_round = endRound + CombatM.getRound();
        end

        -- 同步一下回合数
        if condition.prop then
            condition["prop"][4] = condition.end_round;
        end

        condition.status = nil;

        CombatStatusM.applyStatus(target, status, condition);
    end,
};
